package com.demo.config;

import com.demo.service.HelloService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//说明当前类是个配置类,用来替代之前的sping配置文件(beans.xml)
@Configuration
public class MyAppConfig {
    //将方法的返回值添加到容器中,容器默认的ID就是方法名
    @Bean
    public HelloService helloService() {
        System.out.println("配置类@Bean给容器中添加组件....");
        return new HelloService();
    }
}
